﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Threading.Tasks;

namespace BartonExtension
{
    public class OPWebClient : WebClient
    {
        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
            request.Timeout = 1000 * 5;
            request.ReadWriteTimeout = 1000 * 5;
            return request;
        }
    }
    public class HttpDownloader
    {
        public static bool Get(string url,string filePath)
        {
            try
            {
                using (OPWebClient wc = new OPWebClient())
                {
                    wc.DownloadFile(url, filePath);
                }
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }
}
